package com.example.test.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Cavan
 * @date 2023-06-15
 * @qq 2069543852
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    //通过配置，不需要给每一个访问thymeleaf模板页面单独开发一个controller
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //ViewController：请求路径   ViewName：跳转视图
        registry.addViewController("login").setViewName("login");
        registry.addViewController("index").setViewName("index");
    }
}
